home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple WWDC 1996
/
WWDC96_1996 (CD).toast
/
Technology Materials
/
MacOS 8 Resources
/
Developer Tools
/
Mac OS 8 Interfaces & Libraries
/
Interfaces
/
CIncludes
/
GXMath.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-01
|
7KB
|
237 lines
/*
File: GXMath.h
Contains: QuickDraw GX math routine interfaces.
Version: Technology: Quickdraw GX 1.1
Release: Universal Interfaces 3.0d3 on Copland DR1
Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
Bugs?: If you find a problem with this file, send the file and version
information (from above) and the problem description to:
Internet: apple.bugs@applelink.apple.com
AppleLink: APPLE.BUGS
*/
#ifndef __GXMATH__
#define __GXMATH__
#ifndef __CONDITIONALMACROS__
#include <ConditionalMacros.h>
#endif
#ifndef __TYPES__
#include <Types.h>
#endif
#ifndef __FIXMATH__
#include <FixMath.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
#if defined(__MWERKS__) && GENERATING68K
#pragma push
#pragma pointers_in_D0
#endif
struct gxPoint {
Fixed x;
Fixed y;
};
typedef struct gxPoint gxPoint;
typedef unsigned short gxColorValue;
struct gxPolar {
Fixed radius;
Fixed angle;
};
typedef struct gxPolar gxPolar;
struct gxMapping {
Fixed map[3][3];
};
typedef struct gxMapping gxMapping;
#define gxColorValue1 ((gxColorValue) 0x0000FFFF)
#define gxPositiveInfinity ((long) 0x7FFFFFFFL)
#define gxNegativeInfinity ((long) 0x80000000L)
#if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
extern gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source)
THREEWORDINLINE(0x303C, 0x0031, 0xA832);
extern gxMapping *InvertMapping(gxMapping *target, const gxMapping *source)
THREEWORDINLINE(0x303C, 0x0032, 0xA832);
extern gxMapping *MapMapping(gxMapping *target, const gxMapping *source)
THREEWORDINLINE(0x303C, 0x0033, 0xA832);
extern gxMapping *MoveMapping(gxMapping *target, Fixed hOffset, Fixed vOffset)
THREEWORDINLINE(0x303C, 0x0034, 0xA832);
extern gxMapping *MoveMappingTo(gxMapping *target, Fixed hPosition, Fixed vPosition)
THREEWORDINLINE(0x303C, 0x0035, 0xA832);
extern gxMapping *NormalizeMapping(gxMapping *target)
THREEWORDINLINE(0x303C, 0x0036, 0xA832);
extern gxMapping *RotateMapping(gxMapping *target, Fixed angle, Fixed xCenter, Fixed yCenter)
THREEWORDINLINE(0x303C, 0x0037, 0xA832);
extern gxMapping *ScaleMapping(gxMapping *target, Fixed hFactor, Fixed vFactor, Fixed xCenter, Fixed yCenter)
THREEWORDINLINE(0x303C, 0x0038, 0xA832);
extern gxMapping *ResetMapping(gxMapping *target)
THREEWORDINLINE(0x303C, 0x0039, 0xA832);
extern gxMapping *SkewMapping(gxMapping *target, Fixed skewX, Fixed skewY, Fixed xCenter, Fixed yCenter)
THREEWORDINLINE(0x303C, 0x003A, 0xA832);
extern void MapPoints(const gxMapping *source, long count, gxPoint vector[])
THREEWORDINLINE(0x303C, 0x003B, 0xA832);
extern short FirstBit(unsigned long x)
THREEWORDINLINE(0x303C, 0x003C, 0xA832);
extern short WideScale(const wide *source)
THREEWORDINLINE(0x303C, 0x003D, 0xA832);
extern short LinearRoot(Fixed first, Fixed last, Fract t[])
THREEWORDINLINE(0x303C, 0x003E, 0xA832);
extern short QuadraticRoot(Fixed first, Fixed control, Fixed last, Fract t[])
THREEWORDINLINE(0x303C, 0x003F, 0xA832);
extern gxPoint *PolarToPoint(const gxPolar *ra, gxPoint *xy)
THREEWORDINLINE(0x303C, 0x0040, 0xA832);
extern gxPolar *PointToPolar(const gxPoint *xy, gxPolar *ra)
THREEWORDINLINE(0x303C, 0x0041, 0xA832);
extern Fract FractCubeRoot(Fract source)
THREEWORDINLINE(0x303C, 0x0042, 0xA832);
extern Fract FractDivide(Fract dividend, Fract divisor)
THREEWORDINLINE(0x303C, 0x0043, 0xA832);
extern Fract FractMultiply(Fract multiplicand, Fract multiplier)
THREEWORDINLINE(0x303C, 0x0044, 0xA832);
extern Fract FractSineCosine(Fixed degrees, Fract *cosine)
THREEWORDINLINE(0x303C, 0x0045, 0xA832);
extern Fract FractSquareRoot(Fract source)
THREEWORDINLINE(0x303C, 0x0046, 0xA832);
extern Fixed FixedDivide(Fixed dividend, Fixed divisor)
THREEWORDINLINE(0x303C, 0x0047, 0xA832);
extern Fixed FixedMultiply(Fixed multiplicand, Fixed multiplier)
THREEWORDINLINE(0x303C, 0x0048, 0xA832);
/* This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides */
extern long MultiplyDivide(long source, long multiplier, long divisor)
THREEWORDINLINE(0x303C, 0x0049, 0xA832);
extern unsigned long Magnitude(long deltaX, long deltaY)
THREEWORDINLINE(0x303C, 0x004A, 0xA832);
extern long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor)
THREEWORDINLINE(0x303C, 0x004B, 0xA832);
/* wide operations are defined within FixMath.h only for PowerPC */
#if !GENERATINGPOWERPC
extern wide *WideAdd(wide *target, const wide *source)
THREEWORDINLINE(0x303C, 0x004C, 0xA832);
extern short WideCompare(const wide *target, const wide *source)
THREEWORDINLINE(0x303C, 0x004D, 0xA832);
extern wide *WideNegate(wide *target)
THREEWORDINLINE(0x303C, 0x004E, 0xA832);
extern wide *WideShift(wide *target, long shift)
THREEWORDINLINE(0x303C, 0x004F, 0xA832);
extern unsigned long WideSquareRoot(const wide *source)
THREEWORDINLINE(0x303C, 0x0050, 0xA832);
extern wide *WideSubtract(wide *target, const wide *source)
THREEWORDINLINE(0x303C, 0x0051, 0xA832);
extern wide *WideMultiply(long multiplicand, long multiplier, wide *target)
THREEWORDINLINE(0x303C, 0x0052, 0xA832);
/* returns the quotient */
extern long WideDivide(const wide *dividend, long divisor, long *remainder)
THREEWORDINLINE(0x303C, 0x0053, 0xA832);
/* quotient replaces dividend */
extern wide *WideWideDivide(wide *dividend, long divisor, long *remainder)
THREEWORDINLINE(0x303C, 0x0055, 0xA832);
#endif
extern wide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, wide *dot)
THREEWORDINLINE(0x303C, 0x0054, 0xA832);
extern unsigned long RandomBits(long count, long focus)
THREEWORDINLINE(0x303C, 0x0056, 0xA832);
extern void SetRandomSeed(const wide *seed)
THREEWORDINLINE(0x303C, 0x0057, 0xA832);
extern wide *GetRandomSeed(wide *seed)
THREEWORDINLINE(0x303C, 0x0058, 0xA832);
#endif
#define FixedRound(a) ((short)((Fixed)(a) + fixed1/2 >> 16))
#define FixedSquareRoot(a) ((Fixed)FractSquareRoot(a) + 64 >> 7)
#define FixedTruncate(a) ((short)((Fixed)(a) >> 16))
#define FixedToFract(a) ((Fract)(a) << 14)
#define FractToFixed(a) ((Fixed)(a) + 8192L >> 14)
#define FixedToInt(a) ((short)((Fixed)(a) + fixed1/2 >> 16))
#define IntToFixed(a) ((Fixed)(a) << 16)
#define FixedToFloat(a) ((float)(a) / fixed1)
#define FloatToFixed(a) ((Fixed)((float)(a) * fixed1))
#define FractToFloat(a) ((float)(a) / fract1)
#define FloatToFract(a) ((Fract)((float)(a) * fract1))
#define ColorToFract(a) (((Fract) (a) << 14) + ((Fract)(a) + 2 >> 2))
#define FractToColor(a) ((gxColorValue) ((a) - ((a) >> 16) + 8191 >> 14))
#define ff(a) IntToFixed(a)
#define fl(a) FloatToFixed(a)
#if defined(__MWERKS__) && GENERATING68K
#pragma pop
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import off
#endif
#ifdef __cplusplus
}
#endif
#endif /* __GXMATH__ */